<template>
    <load-list 
    ref="list" 
    v-model="tableData" 
    :search="search" 
    :action="action" 
    lazy
    @queryEnd="queryEndHandler"
    >
        <div 
        class="items" 
        v-for="(item,index) in tableData" 
        :key="item.docname" 
        >
            <list-item
            :data="item" 
            :title="`${item.notice}`" 
            :time="item.publishtime" 
            :isBouTime="isBouTime"
            :isTagLong="isTagLong" 
            @titleClick="clickHandler(item, index)" 
            >
                <template slot="content"></template>

                <template slot="icon">
                    <div></div>
                </template>
            </list-item>
        </div>
    </load-list>
</template>

<script>
import notice from '@/mixins/notice.js';

import LoadList from '@components/sys/load-list.vue';
import ListItem from './item.vue';

export default {
    mixins: [notice],
    components: {
        LoadList,
        ListItem,
    },
    props: {
        action: {
            type: String,
            default: '',
        },
        search: {
            type: Object,
            default: () => {},
        },

        isBouTime: {
            type: Boolean,
            default: true,
        },
        afterClick: {
            type: Function,
            default: function () {},
        },
        isTagLong: {
            type: Boolean,
            default: false,
        },
        requiredKey: {
            type: String,
            default: '',
        },

        pageCzc: {
            type: [Boolean, Function],
            default: false,
        },
        clickCzc: {
            type: [Boolean, Function],
            default: false,
        },
    },
    data() {
        return {
            tableData: [],
        };
    },
    watch: {
        requiredKey: {
            handler(n, o) {
                if (n && n !== o) {
                    this.$nextTick(() => {
                        this.$refs.list.queryData(true);
                    });
                }
            },
            immediate: true,
        },
    },
    methods: {
        //跳转页面
        clickHandler(data, index) {
            this.$emit('click', data, index);

            this.openNotice(data.guid, data.noticetype, false);
        },
        queryData(reload = true) {
            this.$refs.list.queryData(reload);
        },
        queryEndHandler(data) {
            this.$emit('queryEnd', data);

            if (data.total && data.current === 1) {
                this.$emit('show');
            }
        }
    },
    mounted() {
        
    },
};
</script>

<style lang="scss" scoped>
.items {
    + .items{
        margin-top: 20px;
    }

    ::v-deep .title {
        width: 100%;
    }
}
</style>
